using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class MenuSett : MonoBehaviour
{
    [SerializeField] private TextMeshProUGUI inputText;
    [SerializeField] private TextMeshProUGUI second_inputText;
    [SerializeField] private TextMeshProUGUI helloText;

    public void SaveNickname() {
        PlayerPrefs.SetString("nickname", inputText.text);
        PlayerPrefs.SetString("second_nickname", second_inputText.text);

        string tempText = "Hello, ";
        if (PlayerPrefs.HasKey("nickname") && PlayerPrefs.GetString("nickname").Length > 1) {
            tempText += PlayerPrefs.GetString("nickname");
            if (PlayerPrefs.HasKey("second_nickname") && PlayerPrefs.GetString("second_nickname").Length > 1) {
                tempText = tempText + " & " + PlayerPrefs.GetString("second_nickname") + "!";
            } else {
                tempText += "!";
                PlayerPrefs.SetString("second_nickname", "Player2");
            }
        } else {
            tempText += "Player!";
            PlayerPrefs.SetString("nickname", "Player1");
            PlayerPrefs.SetString("second_nickname", "Player2");
        }
        
        helloText.text = tempText;
    }

    // Изменение сложности игры (регулировка максимального количетсва врагов в комнате)
    public void SetDifficultyEasy() { PlayerPrefs.SetInt("difficulty", 1); } // Лёгкая
    public void SetDifficultyNormal() { PlayerPrefs.SetInt("difficulty", 2); } // Нормальная
    public void SetDifficultyHard() { PlayerPrefs.SetInt("difficulty", 3); } // Трудная
}
